package sort.MergeSort;

public class MergeTwoToOne {
	
	public int[] merge(int[] a,int[] b){
		int[] c=new int[a.length+b.length];
		int ai=0;int bi=0;int ci=0;
		while(ai<a.length && bi<b.length){
			if(a[ai]<=b[bi]){
				c[ci++]=a[ai++];
		    }else{
		    	c[ci++]=b[bi++];
		    }
		}
		while(ai<a.length){c[ci++]=a[ai++];}
		while(bi<b.length){c[ci++]=b[bi++];}
		
		return c;
	}
}
